﻿namespace X2OPC.Core.DA
{
    using System;
    using System.Runtime.InteropServices;

    [ComImport, ComVisible(true), Guid("39c13a52-011e-11d0-9675-0020afd8adb3"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IOPCSyncIO
    {
        /// <summary>
        /// 以同步方式读取OPCGroup内的OPCItem(s) 的值 
        /// </summary>
        /// <param name="dwSource"></param>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="ppItemValues"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int Read([In, MarshalAs(UnmanagedType.U4)] OPCDataSource dwSource, [In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] int[] phServer, out IntPtr ppItemValues, out IntPtr ppErrors);

        /// <summary>
        ///  以同步方式将值写入OPCGroup 內的 OPCItem(s) 
        /// </summary>
        /// <param name="dwCount"></param>
        /// <param name="phServer"></param>
        /// <param name="pItemValues"></param>
        /// <param name="ppErrors"></param>
        /// <returns></returns>
        [PreserveSig]
        int Write([In] int dwCount, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] int[] phServer, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] object[] pItemValues, out IntPtr ppErrors);
    }
}
